package main

import (
	"os"
	"path/filepath"

	"gitee.com/go-wena/cli"
	"gitee.com/go-wena/proc"
	"gitee.com/go-wena/wena/utils/pathx"
)

func init() {
	cli.New(
		cli.Use("clean", "cls"),
		cli.Comment("清理目录"),
		cli.Run(func(c *cli.Command, args []string) {
			root := pathx.FindPathHasChild("go.mod", false, ".")
			if root != "" {
				cli.CheckErr(os.RemoveAll(filepath.Join(root, ".wena")))
				cli.CheckErr(proc.Context(c.Context()).Command("go", "clean").Start())
			}
		}),
	).AddTo(root)
}
